<?php
require_once('../model/m_login.php');

class login{

	public $logUsername ;
	public $logPassword ;
	public $logDatos = array();
	public $logFullname;
	public $logRole;
	
	public function setValores(){
		$this->logUsername=$_GET['username'];
		$this->logPassword=$_GET['password'];
		}
		
	public function ValidarLogin(){
		
		$this->logDatos = Mlogin($this->logUsername,$this->logPassword);
		$this->logFullname = $this->logDatos[2];
		$this->logRole = $this->logDatos[4];
		
		//print_r($this->datos);
		
		//checks if user is enabled
		if($this->logDatos[3]==1){

			return true;
			
			}else{
				return false;
				}
		}	
	
	}
$ins = new login;
$ins->setValores();
$estado=$ins->ValidarLogin();

if($estado){
	
	session_start(); 
	
	$_SESSION['usr']= $ins->logUsername;
	$_SESSION['name']= $ins->logFullname;
	$_SESSION['role']= $ins->logRole;
	
	
	header("location:../../qshift_change/control/c_q_shifts.php?view=list");
	}else{
		header("location:../../index.php");
		}


?>